var _common_util = require('util/common_util.js');

var _address_service = {
    // 获取地址列表
    getAddressList : function(resolve, reject){
        _common_util.request({
            url     : _common_util.getServerURL('/shipping/list'),
            data    : {
                userID : sessionStorage.getItem('user_id')
            },
            success : resolve,
            error   : reject
        });
    },
    // 新建收件人
    save : function(addressInfo, resolve, reject){
        _common_util.request({
            url     : _common_util.getServerURL('/shipping/insert'),
            method  : 'POST',
            data    : addressInfo,
            success : resolve,
            error   : reject
        });
    },
    // 更新收件人
    update : function(addressInfo, resolve, reject){
        _common_util.request({
            url     : _common_util.getServerURL('/shipping/update'),
            data    : addressInfo,
            success : resolve,
            error   : reject
        });
    },
    // 删除收件人
    deleteAddress : function(shippingId, resolve, reject){
        _common_util.request({
            url     : _common_util.getServerURL('/shipping/delete'),
            data    : {
                shippingId : shippingId
            },
            success : resolve,
            error   : reject
        });
    },
    // 获取单条收件人信息
    getAddress : function(shippingId, resolve, reject){
        _common_util.request({
            url     : _common_util.getServerURL('/shipping/select'),
            data    : {
                shippingId : shippingId
            },
            success : resolve,
            error   : reject
        });
    },
}
module.exports = _address_service;